import {mapState} from "vuex";

export default {
    methods: {
        setTabBar(count) {
            uni.setTabBarBadge({
                index: 2,
                text: count + ''
            })
        }
    },
    computed: {
        ...mapState("shopcartStore", ["shopcartList"])
    },
    onShow() {
        this.setTabBar(this.shopcartList.length)
    },
    watch: {
        shopcartList: {
            handler(newValue, oldValue) {
                this.setTabBar(newValue.length)
            },
        },
    }
}
